<style scoped>
  .supClass{
    font-size: 10px;
    color: #fff;
    background: #f54743;
    border-radius: 5px;
    padding: 2px 4px;
    margin-left: -10px;
    margin-top: -2px;
    white-space: nowrap;
  }
</style>
<template>
  <!--国际化切换-->
  <Dropdown placement="bottom-start" transfer trigger="click" @on-click="changeLanguage">
    <a href="javascript:void(0)" style="margin-left: 10px;color: #2e2e2e;font-size: 20px;">
      <Icon type="md-globe" title="国际语言切换"></Icon>
    </a>
    <DropdownMenu slot="list">
      <DropdownItem name="zh">简体中文</DropdownItem>
      <DropdownItem name="en">English</DropdownItem>
    </DropdownMenu>
  </Dropdown>
</template>

<script>
  export default {
    name:'langNav',
    data(){
      return {
        notice:[],
      }
    },
    methods:{
      changeLanguage(name){
        // 后台同步
        if((name === 'en') && (window.localStorage.language !== 'en')){
          this.changeLang('en_US')
        }else if((name === 'zh') && (window.localStorage.language !== 'zh')){
          this.changeLang('zh_CN')
        }
      },
      changeLang(language){
        if(language == 'en_US'){
          window.localStorage.language = 'en'
        }else{
          window.localStorage.language = 'zh'
        }
        window.location.reload()
        // 国际化语言切换
        /*this.$http({
          url:this.$log+'changeLanguage.do',
          method:'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          data: {
            'language':language
          }
        }).then((response)=>{
          var code = response.data.code
          // console.log(code)
          if(code == 0) {
            var language = response.data.language
            if(language == 'en_US'){
              window.localStorage.language = 'en'
            }else{
              window.localStorage.language = 'zh'
            }
            // console.log(language)
            window.location.reload()
          }else{
            this.$Message.error(response.data.errors)
          }
        })*/
      }
    },
    created () {

    }
  }
</script>
